package com.trs.entry;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;

@Entity
// @Table(name = "cqdocjson")
@Table(name = "cqdocjson", indexes = { @Index(columnList = "serverid"), @Index(columnList = "type"), @Index(columnList = "path"), @Index(columnList = "issend"), @Index(columnList = "createTime"), @Index(columnList = "serverid,type") })
public class DocJson {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;
	private Integer serverid;
	private Integer type;
	@Column(length = 50)
	private String path;
	private String fullpath;
	private String filepath;
	@Lob
	private String content;
	private Integer docid;
	@Column(columnDefinition = "INT default -5", nullable = false)
	private Integer issend;// <0等待重试，0失败，1成功，2过滤，3带文件的消息过滤，4带文件不存在的过滤
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 提交数据为@param
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") // 提交数据为json
	@Temporal(TemporalType.TIMESTAMP) // @TemporalType.(DATE,TIME,TIMESTAMP)分别Map java.sql.(Date,Time, Timestamp).
	private Date createTime;// 发布时间

	public DocJson() {
		super();
	}

	public DocJson(Integer serverid, String fullpath, String path, String content) {
		super();
		this.serverid = serverid;
		this.fullpath = fullpath;
		this.path = path;
		this.content = content;
		this.issend = -5;
		this.createTime = new Date();
		this.type = 0;
	}

	public DocJson(Integer serverid, String path, String content) {
		super();
		this.serverid = serverid;
		this.path = path;
		this.content = content;
		this.issend = -5;
		this.createTime = new Date();
		this.type = 0;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getServerid() {
		return serverid;
	}

	public void setServerid(Integer serverid) {
		this.serverid = serverid;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getFullpath() {
		return fullpath;
	}

	public void setFullpath(String fullpath) {
		this.fullpath = fullpath;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Integer getDocid() {
		return docid;
	}

	public void setDocid(Integer docid) {
		this.docid = docid;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getIssend() {
		return issend;
	}

	public void setIssend(Integer issend) {
		this.issend = issend;
	}

	public String getFilepath() {
		return filepath;
	}

	public void setFilepath(String filepath) {
		this.filepath = filepath;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Override
	public String toString() {
		return "DocJson [id=" + id + ", serverid=" + serverid + ", type=" + type + ", path=" + path + ", fullpath=" + fullpath + ", filepath=" + filepath + ", content=" + content + ", docid=" + docid + ", issend=" + issend + ", createTime=" + createTime + "]";
	}

}
